package com.bstek.uflo.form.view.form;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;

import com.bstek.dorado.annotation.DataProvider;
import com.bstek.dorado.annotation.Expose;
import com.bstek.dorado.data.provider.Page;
import com.bstek.uflo.command.CommandService;
import com.bstek.uflo.form.command.DeleteFormCommand;
import com.bstek.uflo.form.command.QueryFormCommand;
import com.bstek.uflo.form.command.QueryTableCommand;
import com.bstek.uflo.form.model.Form;
import com.bstek.uflo.form.model.TableDefinition;

/**
 * @author Jacky.gao
 * @since 2013年11月13日
 */
@Component("uflo.form.formMaintain")
public class FormMaintain {
	@Autowired
	@Qualifier(CommandService.BEAN_ID)
	private CommandService commandService;
	@DataProvider
	public void loadTables(Page<TableDefinition> page){
		commandService.executeCommand(new QueryTableCommand(page, null));
	}
	@DataProvider
	public List<Form> loadForms(long tableId){
		return commandService.executeCommand(new QueryFormCommand(tableId));
	}
	@Expose
	public void deleteForm(long formId){
		commandService.executeCommand(new DeleteFormCommand(formId));
	}
}
